package top.yxqz.test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Random;

/**
 * @author Mr.余
 * @date 2022/11/27
 * @package top.yxqz.test
 */
@WebServlet("/mydemo")
public class test2 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        String[] students = {"马超", "张飞", "关羽", "赵云", "黄忠"};
        String student = students[new Random().nextInt(students.length)];
        response.getWriter().println("随机一位同学："+student);
    }
}
